import java.util.LinkedList;
import java.util.NoSuchElementException;
import java.util.Queue;

/**
 *
 * @author jillsanluis
 */
public class PacketOrderedQueue {


    private Queue<Packet> packetQueue = new LinkedList<Packet>();
    private static PacketOrderedQueue instance;
    
    private PacketOrderedQueue(){
    }

    public static synchronized PacketOrderedQueue getInstance(){
        if(instance == null){
            instance = new PacketOrderedQueue();
        }

        return instance;
    }

    public Packet pop(){
        try{
            return packetQueue.remove();
        }
        catch(NoSuchElementException nsee){
            // do nothing
        }

        return null;
    }

    public void push(Packet p){
        packetQueue.add(p);
    }
}
